
var log = require("../lib/log");
var config = require('../config');
var crypto = require('crypto');
var RUtil = require('./dataformatUtil');

var wechat = require('wechat');

function index(request, response){
    var message = request.weixin;
    console.log(message);
    if(message.MsgType=='text')
    {
       // response.reply('您来啦，那就好好上网吧');
       if(message.Content=="上网")
       {
           response.reply("点击<a href=\"http://wifigate.sinaapp.com/index.php/Hotspot/appHome.html?autologin&wifitoken=e4da3b7fbbce2345d7772b0674a318d5_5\">我要上网</a>");
       }
    }
    else if(message.MsgType=='event')
    {
        response.reply('您终于来关注我们拉，太开心了，想要无线上网请输入 上网');
    }

}

exports.init = function(app){
    app.use('/weixin', wechat('CLOUDSRV',  function (req, res, next) {
        index(req, res);
    }));
    //在这里只要是注册的商户需要微信认证的都加入进来
}



